<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [10,23,21,2,34,6,7,8,12,23,45,90];
        // sort传入排序函数
        arr.sort(function(a,b) {
            // 大于0.5返回-1否则1
            return Math.random() > 0.5 ? -1 : 1;
        });
        alert(arr);
    </script>
</body>
</html>